package com.itheima.comday06.itheima01;

public class Demo05 {
    public static void main(String[] args) {
        int[] arr = {11, 22, 33, 31, 44, 55, 62, 20};

        System.out.println(getSum(arr));
    }


    //请定义方法getSum()，计算数组中：偶数索引位置上，并且元素是偶数的累加和
    public static int getSum(int[] arr) {
        int sum = 0;

        for (int i = 0; i < arr.length; i++) {
            if (i % 2 == 0 && arr[i] % 2 == 0) {
                sum += arr[i];

            }
        }
        return sum;
    }





}
